#include "ZerglingGroupState.h"

ZerglingGroupState::ZerglingGroupState(ZerglingState* s): _s(s)
{
}

ZerglingGroupState::~ZerglingGroupState()
{
	delete _s;
}

void ZerglingGroupState::addToGroupState(BWAPI::Unit* u)
{
	_set.insert(u);
}

void ZerglingGroupState::preformGroupState()
{
	std::set<BWAPI::Unit*>::iterator it;
	int counter = 0;
	for (it = _set.begin(); it != _set.end(); it++)
	{
		_s->doAction((*it), _s->getDeltaX()*counter, _s->getDeltaY()*counter);
		counter++;
	}
}

void ZerglingGroupState::switchUnitOrders(ZerglingState* s)
{
	delete _s;
	_s = s;
	preformGroupState();
}

void ZerglingGroupState::removeFromState(BWAPI::Unit* u)
{
	_set.erase(u);
}